package com.xunfang.demos;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author lss
 * @CreateTime 2024/6/11
 * @Description
 * 转发是一次请求
 * 我是master分支
 */

@WebServlet("/aServlet")
public class AServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setAttribute("name","zhangsan");
        //转发到BServlet
        //req.getRequestDispatcher("bServlet").forward(req,resp);
        //重定向到bServlet
        resp.sendRedirect("bServlet");

    }
}
